Skip to content

[ui/core] Add Validators paradigm#3088

Open
nicolas-lambert-tc wants to merge 1 commit intodevelopfrom
feature/node-valididy-check-rebased
Open

[ui/core] Add Validators paradigm#3088
nicolas-lambert-tc wants to merge 1 commit intodevelopfrom
feature/node-valididy-check-rebased

Conversation

@nicolas-lambert-tc
Copy link
Copy Markdown
Contributor

Description

Alicevision related PR

Add a standard way to validate the attribute value.
It add a way to apply validators to an attribute description and to represent in the UI when these attributes are not valid.

Screenshot_2025-05-23_17-35-17

image

Validators

class AttributeValidator(object):

    def __call__(self, node: "Node", attribute: "Attribute") -> tuple[bool, list[str]]: raise NotImplementedError()


class NotEmptyValidator(AttributeValidator):

    def __call__(self, node: "Node", attribute: "Attribute") -> tuple[bool, list[str]]:

        if attribute.value is None or attribute.value == "":
            return error("Empty value are not allowed")
        
        return success()

Validators usage (can be a lambda)

desc.StringParam(
            name="input",
            label="Test input",
            description="",
            value="",
            validators=[
                NotEmptyValidator(),
                lambda node, attribute: success() if attribute == "test" else error("Attribute value should be 'test'")
                ]
        ),

Features list

  • Add the notion of reusable validators
  • Validator embed the error messages
  • Validator can be a lambda
  • An icon with error message appear when an attribute value is invalid (at least one validator return error messages)
  • A node containing an invalid attribute is tagged with an orange icon and the selection rectangle is orange
  • Attribute value is checked every time the attribute value is set (in the Command)
  • A Warning Dialog is displayed before trying to submit a graph where a node is in warning state

Comment thread meshroom/core/node.py Fixed
Comment thread meshroom/core/desc/attribute.py Fixed
Comment thread meshroom/core/desc/validators.py Fixed
@nicolas-lambert-tc nicolas-lambert-tc added feature new feature (proposed as PR or issue planned by dev) UI labels Apr 29, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 29, 2026

Codecov Report

❌ Patch coverage is 92.85714% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.62%. Comparing base (0ee8481) to head (b4dfda0).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
meshroom/core/attribute.py 81.25% 6 Missing ⚠️
meshroom/core/desc/attribute.py 92.85% 1 Missing ⚠️
meshroom/core/desc/validators.py 95.23% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3088      +/-   ##
===========================================
+ Coverage    83.47%   83.62%   +0.14%     
===========================================
  Files           81       83       +2     
  Lines        10301    10395      +94     
===========================================
+ Hits          8599     8693      +94     
  Misses        1702     1702              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nicolas-lambert-tc nicolas-lambert-tc force-pushed the feature/node-valididy-check-rebased branch from 5c972ee to 3559a29 Compare April 29, 2026 13:09
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces an attribute “validators” mechanism in meshroom.core and wires it through to the QML UI so invalid attributes and nodes can be visually flagged and warned about on submit.

Changes:

  • Add reusable attribute validators (NotEmptyValidator, RangeValidator) and expose validation state/messages on runtime attributes/nodes.
  • Update Graph Editor QML to display per-attribute and per-node warning indicators (orange styling + tooltip messages).
  • Add tests and a test node description to exercise the new validation behavior.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
meshroom/core/desc/validators.py Adds validator interfaces/helpers and two concrete validators.
meshroom/core/desc/attribute.py Extends attribute description classes to accept validators=.
meshroom/core/attribute.py Executes validators and exposes validation-related properties to the UI layer.
meshroom/core/node.py Adds node-level hasInvalidAttribute property + change signal emission.
meshroom/ui/qml/GraphEditor/AttributeItemDelegate.qml Adds per-attribute warning icon/border and tooltip changes.
meshroom/ui/qml/GraphEditor/Node.qml Adds node-level warning icon and orange selection/border when warnings exist.
meshroom/ui/qml/Application.qml Adds a warning dialog when submitting graphs containing nodes with warnings.
tests/nodes/test/nodeValidators.py Adds a test node description that uses validators.
tests/test_attributes.py Adds tests for NotEmpty and Range validation behavior.
meshroom/common/PySignal.py Allows ClassSignal(...) to accept args/kwargs (for typed-signal parity).
meshroom/core/graph.py Adds a new attributeValueChanged signal (currently only declared).
meshroom/ui/qml/Utils/format.js Guards plainToHtml for falsy inputs.
meshroom/ui/qml/Utils/Colors.qml Adds a warning color constant.
meshroom/ui/commands.py Refactors attribute set to go through a single attribute reference.
Comments suppressed due to low confidence (1)

meshroom/core/desc/attribute.py:4

  • types is imported but not used in this module. Please remove the unused import to keep the file clean (and to avoid failing lint checks if/when they are enabled).
import ast
import os
import re
from collections.abc import Iterable

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/test_attributes.py Outdated
Comment thread meshroom/core/attribute.py
Comment thread meshroom/core/desc/validators.py Outdated
Comment thread tests/nodes/test/nodeValidators.py Outdated
Comment thread meshroom/core/attribute.py
Comment thread meshroom/ui/qml/GraphEditor/AttributeItemDelegate.qml Outdated
Comment thread meshroom/ui/qml/Application.qml Outdated
Comment thread meshroom/ui/qml/GraphEditor/Node.qml Outdated
Comment thread meshroom/core/desc/validators.py Outdated
Comment thread meshroom/core/node.py
Comment on lines 2168 to 2169
def _hasDisplayableShape(self):
"""
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name is declared twice on BaseNode (first as constant=True, then again later with notify=nodeNameChanged). The earlier declaration is redundant and can be misleading; please remove the duplicate name = Property(str, getName, constant=True) to keep a single source of truth for the Qt property.

Copilot uses AI. Check for mistakes.
@nicolas-lambert-tc nicolas-lambert-tc force-pushed the feature/node-valididy-check-rebased branch from 3559a29 to b4dfda0 Compare April 29, 2026 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature new feature (proposed as PR or issue planned by dev) UI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants